package xinyu.customer.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import xinyu.customer.R;

public abstract class BaseCustomBottomDialog extends Dialog {

    public abstract int getLayoutId();

    public abstract void initView();

    public BaseCustomBottomDialog(Context context) {
        super(context, R.style.CustomDialog);
        setContentView(getLayoutId());
        initWindow();
        initView();
    }

    private void initWindow() {
        Window window = getWindow();
        window.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.width = WindowManager.LayoutParams.MATCH_PARENT;
        attributes.height = WindowManager.LayoutParams.WRAP_CONTENT;
        attributes.gravity = Gravity.BOTTOM;
        // 一定要重新设置, 才能生效
        window.setAttributes(attributes);
    }
}
